Public perceptions of multiple risks during the COVID-19 pandemic in Italy and Sweden. Reproducing original findings and extending it with data for Poland.

Mateusz BaryƂa, Konrad Lewszyk

May 26, 2022

Agenda

  1. Searching for the right study
  2. The original study
  3. Survey replication
  4. Extended study
  5. Original data
  6. Gathered data
  7. Steps to preprocess
  8. Functions and good practice coding
  9. Full reproducibility
  10. Results

Searching for the study

What we looked for in our target study:
1. Available data with labeled and coherent variables
2. Available survey process
3. Available codes
4. A realistic reproducible approach

Original Study




Survey replication

Link to our survey: https://docs.google.com/forms/d/e/1FAIpQLSeN__k2KDdbRZIkhZ3ubUIVTXc6kPAtjSIqh1bI07bDzVrpNg/viewform?fbclid=IwAR26g8tf0azKeNHSU1FgNR1wvvhTrOis891X9dU9bBNVU1gdfoan9cZkcVE

Extended study

We extended the study by collecting data from Polish respondents and we managed to get a little over 20 respondents to participate. As the sample we collected was rather small, there was no point in extending the study by Poland’s regional analysis. Therefore we focued on the radar graphs and the perceptions of risk by country.


It is crucial to mention that the study was conducted during the onset of the pandemic in 2020. Our extension of the study was done after the vaccination period and towards the end of the pandemic. This means that our respondents could perceive risk differently now than they have two years ago. Simply put the time factor impacts our study.

Original data

INTNR gender age MUN_ITA NUTS2 V9_1 V9_2 V9_3 V9_4 V9_5 V9_6 V9_7 V9_8 V9_9 V19_1 V19_2 V19_3 V19_4 V19_5 V19_6 V19_7 V19_8 V19_9 V29_1 V29_2 V29_3 V29_4 V29_5 V29_6 V29_7 V29_8 V29_9 V49_1 V49_2 V49_3 V49_4 V49_5 V49_6 V49_7 V49_8 V49_9 V39_1 V39_2 V39_3 V39_4 V39_5 V39_6 V39_7 V39_8 V39_9 V69_1 V69_2 V69_3 V69_4 V69_5 V69_6 V69_7 V69_8 V69_9 V59_1 V59_2 V59_3 V59_4 V59_5 V59_6 V59_7 V59_8 V59_9 V79_1 V79_2 V79_3 V79_4 V79_5 V79_6 V79_7 V79_8 V79_9 V90 V100 V110 V120 V130 vikt kvotgrupp2
400 2 56 16 NA 3 4 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ered data

Sygnatura.czasowa X1..How.likely.do.you.think.it.is.that.you.are.directly.involved.in.the.following.phenomena
Epidemics. X1..How.likely.do.you.think.it.is.that.you.are.directly.involved.in.the.following.phenomena
Floods. X1..How.likely.do.you.think.it.is.that.you.are.directly.involved.in.the.following.phenomena
Droughts. X1..How.likely.do.you.think.it.is.that.you.are.directly.involved.in.the.following.phenomena
Wildfires. X1..How.likely.do.you.think.it.is.that.you.are.directly.involved.in.the.following.phenomena
Earthquakes. X1..How.likely.do.you.think.it.is.that.you.are.directly.involved.in.the.following.phenomena
Terror.attacks. X1..How.likely.do.you.think.it.is.that.you.are.directly.involved.in.the.following.phenomena
Domestic.violence. X1..How.likely.do.you.think.it.is.that.you.are.directly.involved.in.the.following.phenomena
Economic.crises. X1..How.likely.do.you.think.it.is.that.you.are.directly.involved.in.the.following.phenomena
Climate.change. X2..In.case.you.are.directly.involved..how.much.damage.do.you.think.the.following.phenomena.can.cause.to.you
Epidemics. X2..In.case.you.are.directly.involved..how.much.damage.do.you.think.the.following.phenomena.can.cause.to.you
Floods. X2..In.case.you.are.directly.involved..how.much.damage.do.you.think.the.following.phenomena.can.cause.to.you
Droughts. X2..In.case.you.are.directly.involved..how.much.damage.do.you.think.the.following.phenomena.can.cause.to.you
Wildfires. X2..In.case.you.are.directly.involved..how.much.damage.do.you.think.the.following.phenomena.can.cause.to.you
Earthquakes. X2..In.case.you.are.directly.involved..how.much.damage.do.you.think.the.following.phenomena.can.cause.to.you
Terror.attacks. X2..In.case.you.are.directly.involved..how.much.damage.do.you.think.the.following.phenomena.can.cause.to.you
Domestic.violence. X2..In.case.you.are.directly.involved..how.much.damage.do.you.think.the.following.phenomena.can.cause.to.you
Economic.crises. X2..In.case.you.are.directly.involved..how.much.damage.do.you.think.the.following.phenomena.can.cause.to.you
Climate.change. X3..In.case.they.occur.in.Poland..how.much.damage.do.you.think.the.following.phenomena.can.cause.to.others.living.in.Poland
Epidemics. X3..In.case.they.occur.in.Poland..how.much.damage.do.you.think.the.following.phenomena.can.cause.to.others.living.in.Poland
Floods. X3..In.case.they.occur.in.Poland..how.much.damage.do.you.think.the.following.phenomena.can.cause.to.others.living.in.Poland
Droughts. X3..In.case.they.occur.in.Poland..how.much.damage.do.you.think.the.following.phenomena.can.cause.to.others.living.in.Poland
Wildfires. X3..In.case.they.occur.in.Poland..how.much.damage.do.you.think.the.following.phenomena.can.cause.to.others.living.in.Poland
Earthquakes. X3..In.case.they.occur.in.Poland..how.much.damage.do.you.think.the.following.phenomena.can.cause.to.others.living.in.Poland
Terror.attacks. X3..In.case.they.occur.in.Poland..how.much.damage.do.you.think.the.following.phenomena.can.cause.to.others.living.in.Poland
Domestic.violence. X3..In.case.they.occur.in.Poland..how.much.damage.do.you.think.the.following.phenomena.can.cause.to.others.living.in.Poland
Economic.crises. X3..In.case.they.occur.in.Poland..how.much.damage.do.you.think.the.following.phenomena.can.cause.to.others.living.in.Poland
Climate.change. X4..How.prepared.do.you.think.the.responsible.authorities.in.Poland.are.to.face.the.following.phenomena
Epidemics. X4..How.prepared.do.you.think.the.responsible.authorities.in.Poland.are.to.face.the.following.phenomena
Floods. X4..How.prepared.do.you.think.the.responsible.authorities.in.Poland.are.to.face.the.following.phenomena
Droughts. X4..How.prepared.do.you.think.the.responsible.authorities.in.Poland.are.to.face.the.following.phenomena
Wildfires. X4..How.prepared.do.you.think.the.responsible.authorities.in.Poland.are.to.face.the.following.phenomena
Earthquakes. X4..How.prepared.do.you.think.the.responsible.authorities.in.Poland.are.to.face.the.following.phenomena
Terror.attacks. X4..How.prepared.do.you.think.the.responsible.authorities.in.Poland.are.to.face.the.following.phenomena
Domestic.violence. X4..How.prepared.do.you.think.the.responsible.authorities.in.Poland.are.to.face.the.following.phenomena
Economic.crises. X4..How.prepared.do.you.think.the.responsible.authorities.in.Poland.are.to.face.the.following.phenomena
Climate.change. X5..In.case.you.are.directly.involved..how.prepared.do.you.think.you.are.to.face.the.following.phenomena
Epidemics. X5..In.case.you.are.directly.involved..how.prepared.do.you.think.you.are.to.face.the.following.phenomena
Floods. X5..In.case.you.are.directly.involved..how.prepared.do.you.think.you.are.to.face.the.following.phenomena
Droughts. X5..In.case.you.are.directly.involved..how.prepared.do.you.think.you.are.to.face.the.following.phenomena
Wildfires. X5..In.case.you.are.directly.involved..how.prepared.do.you.think.you.are.to.face.the.following.phenomena
Earthquakes. X5..In.case.you.are.directly.involved..how.prepared.do.you.think.you.are.to.face.the.following.phenomena
Terror.attacks. X5..In.case.you.are.directly.involved..how.prepared.do.you.think.you.are.to.face.the.following.phenomena
Domestic.violence. X5..In.case.you.are.directly.involved..how.prepared.do.you.think.you.are.to.face.the.following.phenomena
Economic.crises. X5..In.case.you.are.directly.involved..how.prepared.do.you.think.you.are.to.face.the.following.phenomena
Climate.change. X6..How.knowledgeable.are.the.responsible.authorities.in.Poland.on.the.following.phenomena
Epidemics. X6..How.knowledgeable.are.the.responsible.authorities.in.Poland.on.the.following.phenomena
Floods. X6..How.knowledgeable.are.the.responsible.authorities.in.Poland.on.the.following.phenomena
Droughts. X6..How.knowledgeable.are.the.responsible.authorities.in.Poland.on.the.following.phenomena
Wildfires. X6..How.knowledgeable.are.the.responsible.authorities.in.Poland.on.the.following.phenomena
Earthquakes. X6..How.knowledgeable.are.the.responsible.authorities.in.Poland.on.the.following.phenomena
Terror.attacks. X6..How.knowledgeable.are.the.responsible.authorities.in.Poland.on.the.following.phenomena
Domestic.violence. X6..How.knowledgeable.are.the.responsible.authorities.in.Poland.on.the.following.phenomena
Economic.crises. X6..How.knowledgeable.are.the.responsible.authorities.in.Poland.on.the.following.phenomena
Climate.change. X7..How.knowledgeable.are.you.on.the.following.phenomena
Epidemics. X7..How.knowledgeable.are.you.on.the.following.phenomena
Floods. X7..How.knowledgeable.are.you.on.the.following.phenomena
Droughts. X7..How.knowledgeable.are.you.on.the.following.phenomena
Wildfires. X7..How.knowledgeable.are.you.on.the.following.phenomena
Earthquakes. X7..How.knowledgeable.are.you.on.the.following.phenomena
Terror.attacks. X7..How.knowledgeable.are.you.on.the.following.phenomena
Domestic.violence. X7..How.knowledgeable.are.you.on.the.following.phenomena
Economic.crises. X7..How.knowledgeable.are.you.on.the.following.phenomena
Climate.change. X8..Have.you.ever.been.directly.involved.in.the.following.phenomena..in.Poland.or.abroad
Epidemics. X8..Have.you.ever.been.directly.involved.in.the.following.phenomena..in.Poland.or.abroad
Floods. X8..Have.you.ever.been.directly.involved.in.the.following.phenomena..in.Poland.or.abroad
Droughts. X8..Have.you.ever.been.directly.involved.in.the.following.phenomena..in.Poland.or.abroad
Wildfires. X8..Have.you.ever.been.directly.involved.in.the.following.phenomena..in.Poland.or.abroad
Earthquakes. X8..Have.you.ever.been.directly.involved.in.the.following.phenomena..in.Poland.or.abroad
Terror.attacks. X8..Have.you.ever.been.directly.involved.in.the.following.phenomena..in.Poland.or.abroad
Domestic.violence. X8..Have.you.ever.been.directly.involved.in.the.following.phenomena..in.Poland.or.abroad
Economic.crises. X8..Have.you.ever.been.directly.involved.in.the.following.phenomena..in.Poland.or.abroad
Climate.change. X9..What.is.the.highest.level.of.education.you.achieved. X10..To.satisfy.your.family.needs..your.household.income.is. X11..Do.you.have.a.job. X12..Which.of.the.following.categories.best.represent.the.sector.in.which.you.are.employed. What.is.your.gender. What.is.your.age.
2022/05/14 6:33:48 PM EET 5 Very likely 5 Very likely 4 4 4 4 5 Very likely 5 Very likely 5 Very likely 5. Severe damage 5. Severe damage 4 3 2 3 4 5. Severe damage 4 5. Severe damage 5. Severe damage 4 5. Severe damage 4 4 5. Severe damage 4 4 5. Highly prepared 5. Highly prepared 4 3 3 2 2 2 3 5. Highly prepared 4 5. Highly prepared 3 3 4 4 3 2 3 4 3 4 3 2 4 3 3 5. Highly knowledgeable 4 3 4 5. Highly knowledgeable 5. Highly knowledgeable 4 5. Highly knowledgeable 4 yes yes no no yes yes yes yes no University degree or higher 4 Yes IT & telecommunications Male 18
2022/05/18 4:13:26 PM EET 5 Very likely 3 2 1. Not likely at all 1. Not likely at all 5 Very likely 3 5 Very likely 4 5. Severe damage 3 3 2 1. No damage 5. Severe damage 5. Severe damage 5. Severe damage 5. Severe damage 4 4 3 4 4 2 2 5. Severe damage 5. Severe damage 4 2 1. Not at all prepared 1. Not at all prepared 1. Not at all prepared 5. Highly prepared 5. Highly prepared 4 3 5. Highly prepared 3 3 3 3 1. Not at all prepared 3 4 3 5. Highly knowledgeable 4 2 1. Not at all knowledgeable 2 4 4 3 5. Highly knowledgeable 5. Highly knowledgeable 3 3 2 2 2 2 5. Highly knowledgeable 3 yes yes no no no yes no yes no University degree or higher 4 Yes IT & telecommunications Male 25
2022/05/18 5:37:35 PM EET 4 1. Not likely at all 3 1. Not likely at all 1. Not likely at all 1. Not likely at all 1. Not likely at all 1. Not likely at all 2 3 I don’t know 2 I don’t know I don’t know I don’t know I don’t know I don’t know 3 3 3 2 1. No damage 1. No damage 2 3 4 3 3 2 2 1. Not at all prepared 1. Not at all prepared 1. Not at all prepared 1. Not at all prepared 1. Not at all prepared 2 3 I don’t know 2 I don’t know I don’t know I don’t know I don’t know 3 2 3 2 2 1. Not at all knowledgeable 1. Not at all knowledgeable 1. Not at all knowledgeable 2 2 2 3 2 2 2 2 2 2 4 4 Yes No Yes Yes Yes No No Yes Yes University degree or higher 5 No IT & telecommunications Male 26
2022/05/20 1:34:34 PM EET 4 1. Not likely at all 2 1. Not likely at all 1. Not likely at all 2 3 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 2 2 2 2 2 2 1. Not at all prepared 1. Not at all prepared 1. Not at all prepared 4 2 2 2 2 1. Not at all prepared 3 3 2 1. Not at all knowledgeable 2 2 2 2 1. Not at all knowledgeable 1. Not at all knowledgeable 1. Not at all knowledgeable 1. Not at all knowledgeable 2 2 2 2 2 2 2 2 2 Yes No No No No No No Yes Yes University degree or higher 4 Yes Bank, finance and insurance Female 26
2022/05/20 1:50:32 PM EET 5 Very likely 3 3 2 1. Not likely at all 3 3 3 4 4 3 3 2 1. No damage 4 4 4 4 5. Severe damage 4 4 3 1. No damage 5. Severe damage 5. Severe damage 5. Severe damage 5. Severe damage 2 4 2 4 1. Not at all prepared 4 3 2 2 4 4 4 4 4 3 3 3 2 2 4 4 3 1. Not at all knowledgeable 4 4 2 2 3 1. Not at all knowledgeable 1. Not at all knowledgeable 1. Not at all knowledgeable 1. Not at all knowledgeable 3 4 3 3 Yes No No No Yes No Yes Yes Yes University degree or higher 5 Yes IT & telecommunications Male 26
2022/05/20 2:44:31 PM EET 5 Very likely 2 3 2 1. Not likely at all 2 2 4 4 3 4 3 4 5. Severe damage 3 5. Severe damage 4 3 4 4 3 3 2 3 4 4 3 3 3 3 3 2 2 3 2 2 4 2 2 2 2 2 3 3 2 3 3 3 2 2 3 3 2 2 3 2 2 2 2 3 3 4 2 Yes No No No No Yes No Yes Yes University degree or higher 4 No Other category Male 24

Steps to preprocess

Functions and good practice coding

Functions

Defining functions for data preparation and graphing

Specific column selection function
#' Returns tibble with only necessary columns for aggregation.
#'
#' @param dataframe_to_derive_column_names A tibble based on which the necessary columns will be derived.
#' @param dataframe_to_modify A tibble that will be used for subsetting.
#' @param start index of the first column
#' @param end index of the last column
#' @return tibble only with columns between start and end indexes and an area column
derive_necessary_columns <- function(dataframe_to_derive_column_names, dataframe_to_modify, start, end){
  only_columns_for_chart <- dataframe_to_derive_column_names[,c(start:end, 85)] %>% names()

  final_dataframe <- dataframe_to_modify %>% select(all_of(only_columns_for_chart))
  return(final_dataframe)
}
Data aggregation function
#' Returns tibble aggregated by the chosen variable.
#'
#' @param dataset A tibble based on which the necessary columns will be derived.
#' @param start index of the first column
#' @param end index of the last column
#' @param aggregating_variable the grouping column
#' @return aggregated tibble
aggregate_method <- function(dataset, start, end, aggregating_variable){
  return(aggregate(dataset[,start:end], by = list(aggregating_variable),
                   FUN = mean, na.rm = TRUE))
}
Specific country data preparation function
#' Returns complete dataframe for a country, with the structure that is required by
#' by radarchart function from fmsb library.
#'
#' @param dataframe_1 First dataframe
#' @param dataframe_2 index of the first column
#' @param row_to_select index of the row to select from the final DataFrame
#' @param rowname_1 name of the first rowname
#' @param rowname_2 name of the second rowname
#' @return dataframe for the country
derive_dataframe_for_country <- function(dataframe_1, dataframe_2, row_to_select,
                                         rowname_1, rowname_2){
  colnames(dataframe_1) <- c("area", "Epidemics", "Floods", "Drought", "Wildfires", "Earthquakes",
                             "Terror attacks", "Domestic violence", "Economic crises", "Climate Change")
  colnames(dataframe_2) <- c("area", "Epidemics", "Floods", "Drought", "Wildfires", "Earthquakes",
                             "Terror attacks", "Domestic violence", "Economic crises", "Climate Change")
  df_to_return <- rbind(dataframe_1[row_to_select,], dataframe_2[row_to_select,])
  df_to_return <- df_to_return[,2:10]
  rownames(df_to_return) <- c(rowname_1, rowname_2)
  df_to_return <- rbind(rep(5,9) , rep(1,9) , df_to_return) #needed for creating radarchart successfully
  return(df_to_return)
}
Graphing function
#' Plots the radarchart based on the provided DataFrame, with the given title,
#' The labels in the legend correspond to legend_1 and legend_2.
#'
#' @param dataframe dataframe that is required by radarchart function from fmsb library.
#' @param title title to put on the chart
#' @param legend_1 legend for the first froup
#' @param legend_2 legend for the second group
#' @return dataframe for the country
graph_radar <- function(dataframe, title, legend_1, legend_2){
  graph <- radarchart(dataframe,
                      axistype = 1 ,
                      #customize the polygons
                      pcol = colors_border,
                      #pfcol = , # for filling the polygons
                      pty = 32,
                      plwd = 2,
                      plty = 1,
                      #customize the grid
                      cglcol = "grey",
                      cglty = 1,
                      axislabcol = "grey",
                      caxislabels = seq(1,5,1),
                      cglwd = 0.8,
                      #custom labels
                      vlcex = 0.9,
                      title = title)
  legend(x = 1.5, y = 1, legend = c(legend_1, legend_2),
         bty = "n", pch = 20 , col = colors_border, text.width = 2, cex = 0.8, pt.cex = 2)
}

Full reproducibility

  1. Groundhog library for reproducible environment
  2. GitHub for working on code (we created issue and PR, as well as merge to master branch)
  3. Google Drive for storing data (we know that storing data on public repository is not a good practice)

Results

Damage


Preparedness


Knowledge

Sources

Original study: https://www.nature.com/articles/s41597-020-00778-7?fbclid=IwAR1GqAQNW6oCa3gQLC9JEpVaJBAw8SBcc7fobxNX5ybJzwzZvirVxixXVlY